﻿@model Unijovem.UI.Models.DevocionalModel
@{
    ViewBag.Title = "Criar";
}
<link href="@Url.Content("~/Content/jquery.cleditor.css")" rel="stylesheet" type="text/css" />
<link href="@Url.Content("~/Content/jquery-ui-1.8.16.custom.css")" rel="stylesheet" type="text/css" />
<script src="@Url.Content("~/Scripts/jquery.cleditor.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.cleditor.xhtml.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery-ui.min.js")" type="text/javascript"></script>
<script type="text/javascript">
    $(document).ready(function () {
        $("#Descricao").cleditor();
        $("#dialog-modal").hide();

        $("#PreVisualizar").click(function () {
            $("#dialog:ui-dialog").dialog("destroy");

            if ($("#Descricao").val() != "") {
                $("#dialog-modal").html($("#Titulo").val() + "<br />" + $("#Autor").val() + "<br /><br />" + $("#Descricao").val());
            }
            else {
                $("#dialog-modal").html('Não há texto para visualização.');
            }

            $("#dialog-modal").dialog({
                height: 550,
                width: 750,
                modal: true,
                resizable: false
            });
        });
    });
</script>
<div id="dialog-modal" title="Pré-visualização">
</div>
@Html.HiddenFor(model => model.Id)
<h2>
    Criar</h2>
@using (Html.BeginForm())
{
    @Html.ValidationSummary(true)
    <fieldset>
        <legend>DevocionalModel</legend>
        <div class="editor-label">
            @Html.LabelFor(model => model.Titulo)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Titulo)
            @Html.ValidationMessageFor(model => model.Titulo)
        </div>
        <div class="editor-label">
            @Html.LabelFor(model => model.Descricao)
        </div>
        <div class="editor-field">
            @Html.TextAreaFor(model => model.Descricao)
            @Html.ValidationMessageFor(model => model.Descricao)
        </div>
        <a href="#" id="PreVisualizar">Visualizar descrição</a>
        <div class="editor-label">
            @Html.LabelFor(model => model.UrlEmbedYouTube)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.UrlEmbedYouTube)
            @Html.ValidationMessageFor(model => model.UrlEmbedYouTube)
        </div>
        <div class="editor-label">
            @Html.LabelFor(model => model.IdAutor)
        </div>
        <div class="editor-field">
            @Html.DropDownListFor(model => model.IdAutor, (SelectList)ViewBag.Autores)
            @Html.ValidationMessageFor(model => model.IdAutor)
        </div>
        <div class="editor-label">
            @Html.LabelFor(model => model.DataInicio)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.DataInicio)
            @Html.ValidationMessageFor(model => model.DataInicio)
        </div>
        <div class="editor-label">
            @Html.LabelFor(model => model.DataFim)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.DataFim)
            @Html.ValidationMessageFor(model => model.DataFim)
        </div>
        <p>
            <input type="submit" value="Create" />
        </p>
    </fieldset>
}
<div>
    @Html.ActionLink("Back to List", "Index")
</div>
